Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid divisions by zero #1123

Merged
merged 2 commits into from
May 30, 2019
Merged

Avoid divisions by zero #1123

merged 2 commits into from
May 30, 2019

Conversation

JustinDrake
Copy link
Collaborator

Possible fix to avoid four cases of divisions by zero:

  • return state.validator_registry[index].effective_balance // adjusted_quotient // BASE_REWARDS_PER_EPOCH
  • rewards[index] += get_base_reward(state, index) * attesting_balance // total_balance
  • validator.effective_balance * min(total_penalties * 3, total_balance) // total_balance
  • rewards[index] += base_reward * attesting_balance // committee_balance

See also #1107.

Possible fix to avoid four cases of divisions by zero:

* `return state.validator_registry[index].effective_balance // adjusted_quotient // BASE_REWARDS_PER_EPOCH`
* `rewards[index] += get_base_reward(state, index) * attesting_balance // total_balance`
* `validator.effective_balance * min(total_penalties * 3, total_balance) // total_balance`
* `rewards[index] += base_reward * attesting_balance // committee_balance`

See also #1107.
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach. Thoughts on my one comment?

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
@djrtwo djrtwo merged commit 2aea4b9 into dev May 30, 2019
@djrtwo djrtwo deleted the JustinDrake-patch-14 branch May 30, 2019 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants